<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
<title>来回拖动图片</title>
<link href="css/style.css" type="text/css" rel="stylesheet">
</head>
<body>
<div class="mr-cont">
	<h1>拖放图片</h1>
   	<div id="left" ondragover="dragover(event)" ondrop="drop(event)">
   		<img src="img/face.png" id="pic">
   	</div>
  	<div id="right" ondragover="dragover(event)" ondrop="drop(event)"></div>
</div>
<script type="text/javascript">
	var pic = document.getElementById("pic");//获取被拖放的元素
	function dragover(e){
		e.preventDefault();//阻止默认行为，即允许被拖动
	}
	function drop(e){
		e.preventDefault();//阻止默认行为，即允许被拖动
		e.target.appendChild(pic);//移动被拖放的元素
	}
</script>
</body>
</html>
